<?php
class ParamComponent extends Object {
	
	/**
	 * Get Keyword ...
	 * @param $this->params $params
	 * @return unknown|NULL
	 */
	function getKeyword($params) {
		if(!empty($params['url']['keyword'])) {
			return $params['url']['keyword'];
		} else if(!empty($params['named']['keyword'])) {
			return $params['named']['keyword'];
		}
		return null;		
	}
	
	/**
	 * Get Category ...
	 * @param $this->params $params
	 * @return unknown|NULL
	 */
	function getCategory($params) {
		if(!empty($params['category'])) {
			return intval($params['category']);			
		} else if(!empty($params['url']['category'])) {
			return intval($params['url']['category']);
		} else if(!empty($params['named']['category'])) {
			return intval($params['named']['category']);
		}
		return 0;
	}
	
	/**
	 * Get Username ...
	 * @param $this->params $params
	 * @return unknown|NULL
	 */
	function getUsername($params) {
		if(!empty($params['user'])) {
			return $params['user'];			
		} else if(!empty($params['url']['user'])) {
			return $params['url']['user'];
		} else if(!empty($params['named']['user'])) {
			return $params['named']['user'];
		}
		return null;		
	}
	
	/**
	 * Get price from ...
	 * @param $this->params $params
	 * @return unknown|NULL
	 */
	function getPriceFrom($params) {
	
		if(!empty($params['from'])) {
			return intval($params['from']);			
		} else if(!empty($params['url']['from'])) {
			return intval($params['url']['from']);
		} else if(!empty($params['named']['from'])) {
			return intval($params['named']['from']);
		}
		return null;		
	}
	
	/**
	 * Get price to ...
	 * @param $this->params $params
	 * @return unknown|NULL
	 */
	function getPriceTo($params) {
		if(!empty($params['to'])) {
			return intval($params['to']);			
		} else if(!empty($params['url']['to'])) {
			return intval($params['url']['to']);
		} else if(!empty($params['named']['to'])) {
			return intval($params['named']['to']);
		}
		return null;
	}
	
	/**
	 * Get memberID ...
	 * @param $this->params $params
	 * @return unknown|NULL
	 */
	function getMemberID($params) {
		if(!empty($params['id'])) {
			return $params['id'];			
		} else if(!empty($params['url']['id'])) {
			return $params['url']['id'];
		} else if(!empty($params['named']['id'])) {
			return $params['named']['id'];
		}
		return null;		
	}
	
	/**
	 * Get Username ...
	 * @param $this->params $params
	 * @return unknown|NULL
	 */
	function getCity($params) {
		if(!empty($params['city'])) {
			return intval($params['city']);			
		} else if(!empty($params['url']['city'])) {
			return intval($params['url']['city']);
		} else if(!empty($params['named']['city'])) {
			return intval($params['named']['city']);
		}
		return null;		
	}
	
	/**
	 * Get Date From ...
	 * @param $this->params $params
	 * @return unknown|NULL
	 */
	function getDateFrom($params) {
		if(!empty($params['from'])) {
			return date('Y/m/d', strtotime($params['from']));			
		} else if(!empty($params['url']['from'])) {
			return date('Y/m/d', strtotime($params['url']['from']));
		} else if(!empty($params['named']['from'])) {
			return date('Y/m/d', strtotime($params['named']['from']));
		}
		return null;		
	}
	
	/**
	 * Get Date From ...
	 * @param $this->params $params
	 * @return unknown|NULL
	 */
	function getDateTo($params) {
		if(!empty($params['to'])) {
			return date('Y/m/d', strtotime($params['to']));
		} else if(!empty($params['url']['to'])) {
			return date('Y/m/d', strtotime($params['url']['to']));
		} else if(!empty($params['named']['to'])) {
			return date('Y/m/d', strtotime($params['named']['to']));
		}
		return null;		
	}
	
	/**
	 * Get id ...
	 * @param $this->params $params
	 * @return unknown|NULL
	 */
	function getID($params) {
		if(!empty($params['id'])) {
			return $params['id'];			
		} else if(!empty($params['url']['id'])) {
			return $params['url']['id'];
		} else if(!empty($params['named']['id'])) {
			return $params['named']['id'];
		}
		return null;		
	}
	
	/**
	 * Get alias ...
	 * @param $this->params $params
	 * @return unknown|NULL
	 */
	function getAlias($params) {
		if(!empty($params['alias'])) {
			return $params['alias'];			
		} else if(!empty($params['url']['alias'])) {
			return $params['url']['alias'];
		} else if(!empty($params['named']['alias'])) {
			return $params['named']['alias'];
		}
		return null;		
	}
	
	/**
	 * Get state ...
	 * @param $this->params $params
	 * @return unknown|NULL
	 */
	function getState($params) {
		if(!empty($params['state'])) {
			return $params['state'];			
		} else if(!empty($params['url']['state'])) {
			return $params['url']['state'];
		} else if(!empty($params['named']['state'])) {
			return $params['named']['state'];
		}
		return null;		
	}
	
	/**
	 * Get Invite ...
	 * @param $this->params $params
	 * @return unknown|NULL
	 */
	function getInvite($params) {
		if(!empty($params['invite'])) {
			return $params['invite'];			
		} else if(!empty($params['url']['invite'])) {
			return $params['url']['invite'];
		} else if(!empty($params['named']['invite'])) {
			return $params['named']['invite'];
		}
		return null;
	}
	
	/**
	 * Get Invite ...
	 * @param $this->params $params
	 * @return string|NULL
	 */
	function getReturn($params) {
		if(!empty($params['return'])) {
			return trim($params['return']);
		} else if(!empty($params['url']['return'])) {
			return trim($params['url']['return']);
		} else if(!empty($params['named']['return'])) {
			return trim($params['named']['return']);
		}
		return null;
	}
	
	/**
	 * Get View ...
	 * @param $this->params $params
	 * @return string|NULL
	 */
	function getView($params) {
		if(!empty($params['view'])) {
			return trim($params['view']);
		} else if(!empty($params['url']['view'])) {
			return trim($params['url']['view']);
		} else if(!empty($params['named']['view'])) {
			return trim($params['named']['view']);
		}
		return null;
	}

	/**
	 * Get language ...
	 * @param $this->params $params
	 * @return string|NULL
	 */
	function getLang($params) {
		if(!empty($params['lang'])) {
			return trim($params['lang']);			
		} else if(!empty($params['url']['lang'])) {
			return trim($params['url']['lang']);
		} else if(!empty($params['named']['lang'])) {
			return trim($params['named']['lang']);
		}
		return null;
	}
}
?>
